<form class="layui-form" action="{:url()}" method="post" id="editForm">
    <div class="layui-form-item">
        <label class="layui-form-label">管理员昵称</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input field-nick" name="nick" lay-verify="required" autocomplete="off" placeholder="请输入管理员昵称">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">登录账号</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input field-username" name="username" lay-verify="required" autocomplete="off" placeholder="请输入用户名">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">登陆密码</label>
        <div class="layui-input-inline">
            <input type="password" class="layui-input" name="password" lay-verify="password" autocomplete="off" placeholder="******">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">确认密码</label>
        <div class="layui-input-inline">
            <input type="password" class="layui-input" name="password_confirm" autocomplete="off" placeholder="******">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">联系邮箱</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input field-email" name="email" autocomplete="off" placeholder="请输入邮箱地址">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">联系手机</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input field-mobile" name="mobile" autocomplete="off" placeholder="请输入手机号码">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">默认布局</label>
        <div class="layui-input-inline">
            <input type="radio" class="field-iframe" name="iframe" value="0" title="单页">
            <input type="radio" class="field-iframe" name="iframe" value="1" title="框架" checked>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">启用状态</label>
        <div class="layui-input-inline">
            <input type="radio" class="field-status" name="status" value="1" title="启用" checked>
            <input type="radio" class="field-status" name="status" value="0" title="禁用">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">角色分组</label>
        <div class="layui-input-block">
            {foreach name="roles" id="r" key="k"}
                <input type="checkbox" class="field-role_id" name="role_id[]" value="{$k}" title="{$r}" lay-skin="primary" />
            {/foreach}
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">分配工厂</label>
        <div class="layui-input-block">
            {:Form::checkbox('factory_ids', [], $factoryKV, '', ' lay-skin="primary"')}
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">标签</label>
        <div class="layui-input-inline">
        	<div class="tags" id="tags">
            	<input type="text" id="inputTags" autocomplete="off" placeholder="请输入标签">
            	<input type="hidden" name="tags" id="setTags">
            </div>
        </div>
    </div>
    
    <div class="layui-form-item">
        <div class="layui-input-block">
            {:token()}
            <input type="hidden" class="field-id" name="id">
        </div>
    </div>
    <div class="pop-bottom-bar">
        <button type="submit" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="formSubmit" hisi-data="{pop: true, refresh: true}">提交保存</button>
        <a href="javascript:parent.layui.layer.closeAll();" class="layui-btn layui-btn-primary ml10">取消</a>
    </div>
    </form>
    {include file="block/layui" /}
    <script>
    layui.extend({
    	inputTags:'inputTags/inputTags'
    })
    
    var formData = {:json_encode($formData)};
    layui.use(['form', 'func', 'inputTags'], function() {
        var $ = layui.jquery, form = layui.form;
        layui.func.assign(formData);
        
        var formTags = [];
        var formTagsTmp = [];
        if (formData.hasOwnProperty('tags')) {
        	formTagsTmp = formData.tags.split(',');
        }
        for(var i in formTagsTmp) {
        	if ($.trim(formTagsTmp[i]) != '') {
        		formTags.push(formTagsTmp[i]);
        	}
        }
        
        var inputTags = layui.inputTags;
        inputTags.render({
          	elem:'#inputTags',	// 输入框对象
          	vals:'#setTags',	// 赋值对象
          	content: formTags,
          	aldaBtn: false,
          	done: function(value){
          		//console.log(value);
          	},
          	del: function(value) {
          		//console.log(value);
          	}
        })
        
    });
    </script>